package com.dn.apiopen.service.impl.inner;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dn.apiopen.common.ErrorCode;
import com.dn.apiopen.exception.BusinessException;
import com.dn.apiopen.mapper.UserMapper;
import com.dn.dncommon.model.entity.User;
import com.dn.dncommon.service.InnerUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;


/**
 * 用户服务实现类
 *
 * @author dn
 */
//@Service
@DubboService
@Slf4j
public class InnerUserServiceImpl implements InnerUserService {

    @Resource
    private UserMapper userMapper;

    /**
     * 查询是否分配（accessKey、secretKey）给用户
     *
     * @param accessKey
     * @return
     */
    @Override
    public User getInvokeUser(String accessKey) {
        if (StringUtils.isAnyBlank(accessKey)){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(User::getAccessKey,accessKey);
        return userMapper.selectOne(wrapper);
    }

}




